<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<head>
</head>
<body>
<article class="page-container">
	<form action="" method="post" class="form form-horizontal" id="form1" >
		<div class="row cl">
			<label class="form-label col-xs-4"><span class="c-red">*</span>账号：</label>
			<div class="formControls col-xs-5">
				${account}
				<input type="hidden" id="id" name="id" value="${id}" />
				<input type="hidden" id="account" name="account" value="${account}" />
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4"><span class="c-red">*</span>新密码：</label>
			<div class="formControls col-xs-6">
				<input type="password" class="input-text" placeholder="请填写新密码" id="password" name="password" class="required">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4"><span class="c-red">*</span>确认密码：</label>
			<div class="formControls col-xs-6">
				<input type="password" class="input-text" placeholder="请确认新密码" class="required" equalTo="#password" id="confirmNewPassword" name="confirmNewPassword"/>
			</div>
		</div>
		<div class="row cl">
			<div class="col-xs-4 col-xs-offset-4">
				<input class="btn btn-primary radius"  type="submit"   value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>
	</form>
</article>

<script type="text/javascript">
	$(document).ready(function() {
		$("#form1").validate({
			/* rules: {
			}, */
			messages: {
				confirmNewPassword: {equalTo: "输入与上面相同的密码"}
			},
			submitHandler: function(form){
				$.ajax({
					url:"${ctx}/user/resetLoginPwd.do",
					type:"post",
					data:{"id":$("#id").val(),"password":$("#loginName").val()},
					dataType:"json",
					cache: false,
					async: false,
					success:function(data){
						 if(data.flag==200){
							//关闭当前弹窗
							layer.alert('修改成功', {icon: 1}, function(index){
								var index = parent.layer.getFrameIndex(window.name);
			    				parent.$('.btn-refresh').click();
			    				parent.layer.close(index);
			    				layer.close(index);
							});
		    				
						 }else{
							 layer.msg('修改失败', {
							    	time: 20000, //20s后自动关闭
							    	btn: ['知道了']
								}); 
						 }
					},
					error:function(){
						layer.msg('操作错误', {
					    	time: 20000, //20s后自动关闭
					    	btn: ['知道了']
						}); 
					}
				});
				return false; // 阻止表单自动提交事件
			}/* ,
			errorContainer: "#messageBox",
			errorPlacement: function(error, element) {
				$("#messageBox").text("输入有误，请先更正。");
				if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
					error.appendTo(element.parent().parent());
				} else {
					error.insertAfter(element);
				}
			} */
		});
	});
</script>
</body>
